package com.leyou.common.advice;

import com.leyou.common.exception.LyException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ControllerAdvice {

    @ExceptionHandler(LyException.class)//try
    public ResponseEntity<String> handleException(LyException e){  //catch
        return ResponseEntity.status(e.getStatus()).body(e.getMessage());
    }

}
